package com.nantai.jiafang.nantaijiafang.nt5s.fragments;

import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.nantai.jiafang.nantaijiafang.Data;
import com.nantai.jiafang.nantaijiafang.R;
import com.nantai.jiafang.nantaijiafang.databinding.FragmentUperrorSolveBinding;
import com.nantai.jiafang.nantaijiafang.nt5s.fragments.ViewHolder.Holder_Fragment1;

/**
 * Created by Administrator on 2017/10/25.
 */

public class UpErrorfragment_Solve extends Fragment {
    private FragmentUperrorSolveBinding binding;
    private UpErrorfragment2 upErrorfragment2;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding= DataBindingUtil.inflate(inflater,R.layout.fragment_uperror_solve,container,false);
        Holder_Fragment1 holder_fragment1=new Holder_Fragment1(getContext());
        upErrorfragment2=(UpErrorfragment2)Data.upErrorfragment2;
        binding.imgBacksolve.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getFragmentManager().popBackStack();
            }
        });
        binding.btnUpload.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!TextUtils.isEmpty(binding.editAnalysis.getText().toString())&&!TextUtils.isEmpty(binding.editCause.getText().toString())&&!TextUtils.isEmpty(binding.editSolve.getText().toString())){
                    holder_fragment1.solve(Data.uperror_item.getGuid(),binding.editCause.getText().toString(),binding.editAnalysis.getText().toString(),binding.editSolve.getText().toString()
                    ,binding.checkIsok.isChecked()?"1":"0");
                    upErrorfragment2.onSlove(binding.editAnalysis.getText().toString(),binding.editCause.getText().toString(),binding.editSolve.getText().toString(),binding.checkIsok.isChecked()?"1":"0",Data.MODE);
                }
            }
        });
        return binding.getRoot();
    }
}
